package com.ruoyi.stock.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.stock.domain.QwReplay;
import com.ruoyi.stock.service.IQwReplayService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 回归Controller
 * 
 * @author ruoyi
 * @date 2023-08-16
 */
@RestController
@RequestMapping("/stock/replay")
public class QwReplayController extends BaseController
{
    @Autowired
    private IQwReplayService qwReplayService;

    /**
     * 查询回归列表
     */
    @PreAuthorize("@ss.hasPermi('stock:replay:list')")
    @GetMapping("/list")
    public TableDataInfo list(QwReplay qwReplay)
    {
        startPage();
        List<QwReplay> list = qwReplayService.selectQwReplayList(qwReplay);
        return getDataTable(list);
    }

    /**
     * 导出回归列表
     */
    @PreAuthorize("@ss.hasPermi('stock:replay:export')")
    @Log(title = "回归", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, QwReplay qwReplay)
    {
        List<QwReplay> list = qwReplayService.selectQwReplayList(qwReplay);
        ExcelUtil<QwReplay> util = new ExcelUtil<QwReplay>(QwReplay.class);
        util.exportExcel(response, list, "回归数据");
    }

    /**
     * 获取回归详细信息
     */
    @PreAuthorize("@ss.hasPermi('stock:replay:query')")
    @GetMapping(value = "/{replayId}")
    public AjaxResult getInfo(@PathVariable("replayId") Long replayId)
    {
        return success(qwReplayService.selectQwReplayByReplayId(replayId));
    }

    /**
     * 新增回归
     */
    @PreAuthorize("@ss.hasPermi('stock:replay:add')")
    @Log(title = "回归", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody QwReplay qwReplay)
    {
        return toAjax(qwReplayService.insertQwReplay(qwReplay));
    }

    /**
     * 修改回归
     */
    @PreAuthorize("@ss.hasPermi('stock:replay:edit')")
    @Log(title = "回归", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody QwReplay qwReplay)
    {
        return toAjax(qwReplayService.updateQwReplay(qwReplay));
    }

    /**
     * 删除回归
     */
    @PreAuthorize("@ss.hasPermi('stock:replay:remove')")
    @Log(title = "回归", businessType = BusinessType.DELETE)
	@DeleteMapping("/{replayIds}")
    public AjaxResult remove(@PathVariable Long[] replayIds)
    {
        return toAjax(qwReplayService.deleteQwReplayByReplayIds(replayIds));
    }
}
